package com.kingdee.eas.xbang.task.ui.itface.impl;

import java.net.MalformedURLException;
import java.net.URL;
import java.rmi.Remote;
import java.util.HashSet;
import java.util.Iterator;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Service;
import org.apache.axis.client.Stub;

import com.kingdee.eas.tools.datatask.client.webservice.EASLogin.EASLoginProxy;
import com.kingdee.eas.tools.datatask.client.webservice.EASLogin.EASLoginProxyService;
import com.kingdee.eas.tools.datatask.client.webservice.EASLogin.EASLoginSoapBindingStub;

public class EASLoginProxyServiceLocator extends Service implements EASLoginProxyService {

	public EASLoginProxyServiceLocator(String serverHostName) {
		EASLoginWSDDServiceName = "EASLogin";
		ports = null;
		EASLogin_address = "http://" + serverHostName + ":56898/ormrpc/services/EASLogin";
	}

	public String getEASLoginAddress() {
		return EASLogin_address;
	}

	public String getEASLoginWSDDServiceName() {
		return EASLoginWSDDServiceName;
	}

	public void setEASLoginWSDDServiceName(String name) {
		EASLoginWSDDServiceName = name;
	}

	public EASLoginProxy getEASLogin() throws ServiceException {
		URL endpoint;
		try {
			endpoint = new URL(EASLogin_address);
		} catch (MalformedURLException e) {
			throw new ServiceException(e);
		}
		return getEASLogin(endpoint);
	}

	public EASLoginProxy getEASLogin(URL portAddress) throws ServiceException {
		try {
			EASLoginSoapBindingStub _stub = new EASLoginSoapBindingStub(portAddress, this);
			_stub.setPortName(getEASLoginWSDDServiceName());
			return _stub;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Remote getPort(Class serviceEndpointInterface) throws ServiceException {
		EASLoginSoapBindingStub _stub;
		try {
			_stub = new EASLoginSoapBindingStub(new URL(EASLogin_address), this);
			_stub.setPortName(getEASLoginWSDDServiceName());

			return _stub;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}

	public Remote getPort(QName portName, Class serviceEndpointInterface) throws ServiceException {
		if (portName == null)
			return getPort(serviceEndpointInterface);
		String inputPortName = portName.getLocalPart();
		if ("EASLogin".equals(inputPortName)) {
			return getEASLogin();
		} else {
			Remote _stub = getPort(serviceEndpointInterface);
			((Stub) _stub).setPortName(portName);
			return _stub;
		}
	}

	public QName getServiceName() {
		return new QName("http://127.0.0.1:56898/web/services/EASLogin", "EASLoginProxyService");
	}

	public Iterator getPorts() {
		if (ports == null) {
			ports = new HashSet();
			ports.add(new QName("EASLogin"));
		}
		return ports.iterator();
	}

	private static String EASLogin_address = "http://127.0.0.1:56898/ormrpc/services/EASLogin";
	private String EASLoginWSDDServiceName;
	private HashSet ports;
}
